package com.sharemarking.application.common.service;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;

import com.sharemarking.application.common.entity.Share;
import com.sharemarking.application.common.repository.ShareRepo;

@Service
public class ShareService {

	@Autowired
	private ShareRepo sr;

	public Iterable<Share> getAllShares(){
		return sr.findAll(new Specification<Share>() {
			
			@Override
			public Predicate toPredicate(Root<Share> root, CriteriaQuery<?> cq, CriteriaBuilder cb) {
				 
				return cb.notEqual(root.get("describe1").as(String.class), "ADMINISTRATOR");
			}
		});
	}
	

}
